package com.hspedu.newData.dmsxl.哈希表;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-11 
 * @Version: 1.0
 */

public class LC1941检查是否所有字符出现次数相同 {

    public boolean areOccurrencesEqual(String s) {

        int[] map = new int[26];

        for (int i = 0; i < s.length(); i++) {
            map[s.charAt(i) - 'a']++;
        }

        int f = -1;

        for (int i = 0; i < 26; i++) {
            if (map[i] > 0){
                if (f ==-1) f = map[i];
                else if (f != map[i]) return false;
            }
        }
        return true;

    }

}
